#!/bin/bash
#A机器，传输给B机器MD5值
#这两个脚本要分开写
dir=/data/web/
find $dir -type f > /tmp/dir.txt
[ -f /tmp/md5.txt ] && rm -f /tmp/md5.txt
exec < /tmp/dir.txt
while read line;do
      md5sum $line >> /tmp/md5.txt
done
if [ -f /tmp/md5.txt ];then
      scp -rp -P1314 /tmp/md5.txt 192.168.89.20:/tmp/  &>/dev/null
else
      echo "/tmp/md5.txt不存在"
      exit 1   
fi

#B机器，判断B和A机器文件是否一样
#!/bin/bash
dir=/data/web/
if [ -f /tmp/md5.txt ];then
     md5sum -c /tmp/md5.txt >> /tmp/md5sum.txt
     if [ $? -ne 0 ];then
           echo "192.168.89.30与192.168.89.20文件不相符，请查看/tmp/md5sum.txt文件"
     else
           echo "一切正常"
     fi
else
     echo "md5.txt文件传送异常"
fi